﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using AspNetCs.Common;
using AspNetCs.Bll;
using System.Text;
using AspNetCs.Model;

public partial class PartsOfSite : BasePage
{
    protected int ProvinceId = 0;
    protected int cityId = 0;
    protected City city = new City();
    protected string cityList = "";
    protected void Page_Load(object sender, EventArgs e)
    {
        //DnsRequest.UrlRequestAgentName(out cityId, out ProvinceId);
        if (!IsPostBack)
        {
            ProvinceId = StringHelper.isNumber_int(Request["ProvinceId"]);
            ViewState["ProvinceId"] = ProvinceId;
            DataBindCitys();
        }
        else
        {
            if (ViewState["ProvinceId"] != null)
            {
                ProvinceId = StringHelper.isNumber_int(ViewState["ProvinceId"].ToString());
            }
        }
    }

    private DataTable GetCities()
    {
        DataTable dataTable = new DataTable();
        dataTable = city.CityList(ProvinceId);
        return dataTable;
    }

    public void DataBindCitys()
    {
        StringBuilder sb = new StringBuilder();
        DataTable dataTable = new DataTable();
        dataTable = GetCities();
        if (configInfo.IsDns == 1)
        {
            foreach (DataRow row in dataTable.Rows)
            {
                City_Model CtMd = city.GetModel(row);
                if (CtMd.ClassName.Length > 8)
                {
                    sb.AppendLine("<li style='width:130px; float:left;border-bottom:1px dashed #B5A661;'>");
                }
                else
                {
                    sb.AppendLine("<li style='width:100px; float:left;border-bottom:1px dashed #B5A661;'>");
                }
                sb.Append("<a href='" + (string.IsNullOrEmpty(GetTwoDnsDirect(ProvinceId, CtMd.Id))==true ? configInfo.InstallDir :GetTwoDnsDirect(ProvinceId, CtMd.Id) )+ "Default.aspx'>");
                sb.Append(CtMd.ClassName + "</a>");
                sb.AppendLine("</li>");

            }
        }
        else
        {
            foreach (DataRow row in dataTable.Rows)
            {
                sb.Append("<li><a href='" + configInfo.InstallDir + "Default.aspx'>" + row["ClassName"] + "</a></li>");
            }
        }
        cityList = sb.ToString();
    }
}
